#include "AppFacade.h"

#include "StartUpCommand.h"
#include "LoginCommand.h"

#include "ConstString.h"

/**
 * @brief AppFacade构造函数
 * 初始化父类Facade，并设置外观名称
 */
AppFacade::AppFacade(void)
    :Facade(this, APP_FACADE_NAME)
{

}

/**
 * @brief AppFacade析构函数
 */
AppFacade::~AppFacade(void)
{

}

/**
 * @brief 获取AppFacade单例实例
 * 如果实例不存在则创建新实例，否则返回现有实例
 * @return 返回AppFacade的引用
 */
AppFacade& AppFacade::getInstance(void)
{
    if (Facade::hasCore("AppFacade"))
    {
        return *(dynamic_cast<AppFacade*>(&Facade::getInstance(APP_FACADE_NAME)));
    }
    return *(new AppFacade());
}

/**
 * @brief 初始化外观
 * 调用父类初始化方法并注册所有命令
 */
void AppFacade::initializeFacade(void)
{
    Facade::initializeFacade();

    RegisterAllCommand();
}

/**
 * @brief 注册所有命令
 * 注册启动命令和登录命令到框架中
 */
void AppFacade::RegisterAllCommand()
{
    //ע����������
    registerCommand(STR_NOTIFY_STARTUP, new StartUpCommand());

    //ע���½����
    registerCommand(STR_NOTIFY_LOGIN, new LoginCommand());
}

/**
 * @brief 启动应用程序
 * 发送启动通知，传递应用程序视图指针
 * @param appView 应用程序视图指针
 */
void AppFacade::startUp(void * appView)
{
    sendNotification(STR_NOTIFY_STARTUP, appView);
}